import { createStore } from 'vuex'

const storeFactory = {
    init: (app) => {
        app.use(storeFactory.create())
    },
    create: () => {
        return createStore({
            state: {
                render: []
            },
            mutations: {
                SET_RENDER(state, value) {
                    state.render.push(value)
                },
                SET_ITEM_RENDER(state, param) {
                    state.render[param.index].x = param.x
                    state.render[param.index].y = param.y
                }
            },
            actions: {
                setRender({ commit }, value) {
                    commit('SET_RENDER', value)
                },
                setItemRender({ commit }, value) {
                    commit('SET_ITEM_RENDER', value)
                }
            },
            modules: {}
        })
    }
}

export default storeFactory
